package com.example.spingbootvue.mapper;

import com.example.spingbootvue.entity.employeemessage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface employeemessageMapper {
    //插入招聘的信息在数据库中
    @Insert("INSERT INTO employee(firmname,position,wage,contacts,phone,firmaddress,account) VALUES (#{firmname},#{position},#{wage},#{contacts},#{phone},#{firmaddress},#{account})")
    int insertAll(String firmname,String position ,String wage ,String contacts ,String phone ,String firmaddress,String account);

    //展示所有的招聘信息
    @Select("select * from employee ")
    List<employeemessage> findAll();

    //在record页面展示用户投了哪些简历
    @Select("SELECT * from employeeapply where applicantaccount = #{applicantaccount}")
    List<employeemessage> findresume(String applicantaccount);

    //用户点击投简历按钮将自己的name和account以及发布招聘信息的HR账号传入数据库
    @Insert("INSERT INTO employeeapply(firmname,position,wage,contacts,phone,firmaddress,applicantaccount,applicant,empid,account,educational) VALUES (#{firmname},#{position},#{wage},#{contacts},#{phone},#{firmaddress},#{applicantaccount},#{applicant},#{empid},#{account},#{educational})")
    int insertbyaccount(String firmname,String position,String wage,String contacts,String phone,String firmaddress,String applicantaccount,String applicant,Integer empid,String account,String educational);

    //查询用户是否重复投过此招聘简历
    @Select("SELECT * FROM employeeapply where empid = #{empid} and applicantaccount =#{applicantaccount}")
    employeemessage findById(Integer empid,String applicantaccount);

    //删除求职者所有的申请记录
    @Update("UPDATE employeeapply SET applicantaccount = 'fade' where id=#{id}")
    int updateByaccount(Integer id);

    //HR可以点击忽略屏蔽求职者投的简历
    @Update("UPDATE employeeapply SET account = 'fade' WHERE id = #{id}")
    int updateByempid(Integer id);

    //HR在发布历史界面查询所有发布的招聘信息
    @Select("SELECT * FROM employee WHERE account=#{acount}")
    List<employeemessage> findByaccount(String acount);

    //HR在发布历史界面点击删除即可删除发布记录
    @Delete("DELETE FROM employee WHERE id=#{id}")
    int deletebyid(Integer id);
}
